package com.tjmc.tiomsresource.thread;

import com.tjmc.tiomsresource.parser.AbstractParser;
import com.tjmc.tiomsresource.service.CMSuperService;
import org.dom4j.Element;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * @author Luc
 * @version 1.0
 * @date 2020-05-24 10:42
 */

@Service
public class TranPtnHwPreThread {

    @Async
    public CompletableFuture<Boolean> saveTranPtnHwDataToDB(CMSuperService cmSuperService, List<File> xmlFiles) {
        boolean result = cmSuperService.saveTranPtnHwDataToDB(xmlFiles);
        return CompletableFuture.completedFuture(result);
    }


    @Async
    public <T> CompletableFuture<List<T>> syncParseXML(AbstractParser<T> parser , List<Element> objectElements) {
        List<T> objects = parser.parseXML(objectElements);
        return CompletableFuture.completedFuture(objects);
    }
}
